﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using SF.Base.Core;

namespace SF.Dict.Web {
	public class Global : System.Web.HttpApplication {

		protected void Application_Start(object sender, EventArgs e) {
			Logger.Detail("====================================================================");
			Logger.Detail("Application_Start");

			Dictionary<string, int> DictIdS = new Dictionary<string, int>();

			Logger.Detail("====================================================================");
		}

		protected void Session_Start(object sender, EventArgs e) {

		}

		protected void Application_BeginRequest(object sender, EventArgs e) {

		}

		protected void Application_AuthenticateRequest(object sender, EventArgs e) {

		}

		protected void Application_Error(object sender, EventArgs e) {
			Exception ex = Server.GetLastError();
			if (ex != null) {
				Logger.Exception(ex);

				//Server.ClearError();

				//Response.Redirect("ErrorPage.aspx?msg=" + HttpUtility.UrlEncode(ex.Message), false);
			}
		}

		protected void Session_End(object sender, EventArgs e) {

		}

		protected void Application_End(object sender, EventArgs e) {
			Logger.Detail("====================================================================");
			Logger.Detail("Application_End");
			BaseSettings.Clear();
			Logger.Detail("====================================================================");
		}

		public static UserEntity DTUser {
			get {
				return HttpContext.Current.Session["_DT_USER_"] as UserEntity;
			}
			set {
				HttpContext.Current.Session["_DT_USER_"] = value;
			}
		}
	}
}